import 'package:get/get.dart';

class HomeLogic extends GetxController {
  final banners =
      <String>[
        // 轮播图
        'https://picsum.photos/id/1018/1200/500',
        'https://picsum.photos/id/1015/1200/500',
        'https://picsum.photos/id/1016/1200/500',
      ].obs;

  final actions = const [
    // 四个入口
    {'icon': 0xe7fb, 'label': '消息'}, // Icons.message.codePoint
    {'icon': 0xe88a, 'label': '收藏'}, // Icons.favorite
    {'icon': 0xe0b0, 'label': '联系人'}, // Icons.people
    {'icon': 0xe8b8, 'label': '设置'}, // Icons.settings
  ];

  final items = <Map<String, dynamic>>[].obs; // 列表数据
  final loading = false.obs;

  //  底部导航的当前索引
  final currentTab = 0.obs;

  @override
  void onInit() {
    super.onInit();
    loadList();
  }

  void switchTab(int i) => currentTab.value = i;

  Future<void> loadList() async {
    loading.value = true;
    await Future.delayed(const Duration(milliseconds: 400));
    items.assignAll(
      List.generate(
        20,
        (i) => {
          'id': i + 1,
          'title': '列表项 ${i + 1}',
          'subtitle': '这是第 ${i + 1} 个列表项',
        },
      ),
    );
    loading.value = false;
  }
}
